// 用户模块
export default {
  namespaced: true,
  state () {
    return {
      // 用户信息
      profile: {
        id: '',
        avatar: '',
        username: '',
        email: '',
        mobile: '',
        token: '',
        lastword: '',
        follow: [],
        fans: [],
        friends: [],
        regday: ''
      }
    }
  },
  mutations: {
    // 修改用户信息，payload就是用户信息对象
    setUser (state, payload) {
      state.profile = payload
    },
    editUser (state, payload) {
      state.profile.username = payload.username
      state.profile.email = payload.email
    },
    editLastword (state, lastword) {
      state.profile.lastword = lastword
    },
    // 修改用户的社交关系
    updatestate (state, payload) {
      state.profile.follow = payload.follow
      state.profile.fans = payload.fans
      state.profile.friends = payload.friends
    },
    // 修改用户的头像
    updateAvatar (state, avatar) {
      state.profile.avatar = avatar
    }
  }
}
